<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <ul id="list">
      <li>1</li>
      <li>2</li>
      <li>3</li>
      <!-- + -->
    </ul>

    <script>
      /*
       1. 创建li节点对象
       2. 获取父对象
      */
      const ul = document.getElementById("list");
      const h1 = document.createElement("h1");
      const li = document.createElement("li");
      // li.innerHTML = "new li";
      li.append("new li");
      h1.append("new h1");

      // ul.append(li);
      // ul.prepend(li);
      // ul.before(h1);
      // ul.after(h1);
      ul.replaceWith(h1); // outerHTML
    </script>
  </body>
</html>
